<?php

namespace utils\core;

use EasyWeChat\Factory;

class Wxpay
{
    static public function make($ptype='wxapp')
    {
        var_dump($ptype);
        if(empty($ptype)){
            $ptype='wxapp';
        }
        if($ptype=='wxapp'){
            $app_id = Config::getconfig('miniprogram')['app_id'];
        }elseif($ptype=='mp'){
            $app_id = Config::getconfig('mp')['app_id'];
        }
        
        $wxpay_settings = Paymethod::getwx_settings();

        return Factory::payment([
            'app_id'             => trim($app_id),
            'mch_id'             => trim($wxpay_settings['mchid']),
            'key'                => trim($wxpay_settings['signkey']),
            'cert_path'          => dirname(dirname(dirname(__DIR__))).trim($wxpay_settings['cert_path']), // XXX: 绝对路径！！！！
            'key_path'           => dirname(dirname(dirname(__DIR__))).trim($wxpay_settings['key_path'])  // XXX: 绝对路径！！！！
        ]);
    }
}
